/**
 * 
 */
package com.cbank.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cbank.dao.CompanyDao;
import com.cbank.domain.Company;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:cBank
 * </p>
 * <p>
 * Contact: 1027448479@qq.com
 * </p>
 * 
 * @author Ag
 * @date 2016年12月13日
 */
@Service
public class CompanyService {
	@Autowired
	private CompanyDao dao;

	public Company getById(Long id) {
		Company company = dao.getById(id);
		return company;
	}
public static final int ANY = 0;
	public List<Company> getList(long userId, Integer index, Integer pagerSize, long city, long industry) {

		if (city == ANY && industry != ANY) {// 只选行业
			dao.getPageWithIndustry(userId, index, pagerSize, industry);
		} else if (industry == ANY && city != ANY) {// 只选城市
			dao.getPageWithCity(userId, index, pagerSize, city);
		} else if (industry == ANY && city == ANY) {// 行业城市都没选
			dao.getPage(userId, index, pagerSize);
		} else {// 行业城市都选了
			dao.getPageWithParam(userId, index, pagerSize, city, industry);
		}
		return this.dao.getPage(userId, index, pagerSize);
	}

	public List<Company> getPageWithParam(long userId, Integer index, Integer pagerSize, long city, long industry) {

		return this.dao.getPageWithParam(userId, index, pagerSize, city, industry);
	}

	public Integer getCount() {
		return dao.getCount();
	}
}
